package com.lysj.admin.master.bussiness.company.invoice.service;

import com.lysj.admin.master.common.CommonConstant;
import com.lysj.admin.master.common.spring.mpbase.MyService;
import com.lysj.admin.master.bussiness.company.invoice.domain.InvoiceRecipient;
import com.lysj.admin.master.bussiness.company.invoice.mapper.InvoiceRecipientMapper;
import com.lysj.admin.master.common.web.SelectItem;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Created by drj on 2019-12-27 16:27
 * @description
 */
@Slf4j
@Service
@Transactional
public class InvoiceRecipientService extends MyService<InvoiceRecipientMapper, InvoiceRecipient> {

    @SuppressWarnings("unchecked")
    public List<SelectItem> findByCompanyId(String companyId) {

        return this.lambdaQuery()
                .eq(InvoiceRecipient::getCompanyId, companyId)
                .eq(InvoiceRecipient::getDelFlag, CommonConstant.NORMAL_FLAG)
                .list()
                .stream()
                .map(e -> {
                    return new SelectItem(e.getId(), e.getName());
                })
                .collect(Collectors.toList())
                ;
    }

}
